/*
 * sgutil.h
 *
 *  Created on: 2010. 9. 11.
 *      Author: wanderer
 */

#ifndef SGUTIL_H_
#define SGUTIL_H_

#define SG_UTIL_ENABLE	1

#define SG_ASSERT_LEVEL	SG_LOG_WARN

typedef enum __SG_LOG_LEVEL {
	SG_LOG_DEBUG, SG_LOG_INFO, SG_LOG_WARN, SG_LOG_ERROR, SG_LOG_FATAL
} SG_LOG_LEVEL;

#if SG_UTIL_ENABLE

#define sgAssert(cond, ...)	(!(cond)?__sgAssert(__FILE__,__LINE__,__func__,#cond,__VA_ARGS__):(void)0)

#define sgSetLogLevel(SG_LOG_LEVEL)

#define sgLogDebugMsg(...)	__sgLogMessage(__FILE__,__LINE__,__func__,SG_LOG_DEBUG,__VA_ARGS__)
#define sgLogInfoMsg(...)	__sgLogMessage(__FILE__,__LINE__,__func__,SG_LOG_INFO,__VA_ARGS__)
#define sgLogWarnMsg(...)	__sgLogMessage(__FILE__,__LINE__,__func__,SG_LOG_WARN,__VA_ARGS__)
#define sgLogErrorMsg(...)	__sgLogMessage(__FILE__,__LINE__,__func__,SG_LOG_ERROR,__VA_ARGS__)
#define sgLogFatalMsg(...)	__sgLogMessage(__FILE__,__LINE__,__func__,SG_LOG_FATAL,__VA_ARGS__)

#else

#define sgAssert(cond, ...)

#define sgSetLogLevel(SG_LOG_LEVEL)

#define sgLogDebugMsg(...)
#define sgLogInfoMsg(...)
#define sgLogWarnMsg(...)
#define sgLogErrorMsg(...)
#define sgLogFatalMsg(...)
#define sgLogLineInfo()
#endif

#if SG_UTIL_ENABLE

extern void __sgAssert(const char *file, const int line, const char *func,
		const char *cond, const char *template, ...);

extern void __sgSetLogLevel(SG_LOG_LEVEL level);

extern void __sgLogMessage(const char *file, const int line, const char *func,
		SG_LOG_LEVEL level, const char *template, ...);

#endif

#endif /* SGUTIL_H_ */
